//
//  KoiResult.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 11.05.25.
//

import Foundation
class KoiResult : Equatable {
    
    var resultType: ResultType
    var msg: String?
    
    init(resultType: ResultType, msg: String? = nil) {
        self.resultType = resultType
        self.msg = msg
    }
    
    static func == (lhs: KoiResult, rhs: KoiResult) -> Bool {
        return lhs.resultType == rhs.resultType
    }
    
    static let success = KoiResult(resultType: .success)
    
    static let failure = KoiResult(resultType: .failure)
    
    static let undefined = KoiResult(resultType: .undefined)
    
    func failure(msg: String) {
        resultType = .failure
        self.msg = msg
    }
    
    func reset() {
        resultType = .undefined
    }
}

enum ResultType {
    case success, failure, undefined
}

